//
//  FLLNavigationController.m
//  FLLGodOfCooking
//
//  Created by LL.F on 16/9/1.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "FLLNavigationController.h"
#import "UIView+Frame.h"
#import "FLLMacro.h"

@interface FLLNavigationController ()

@end

@implementation FLLNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // NavigationBar title 字体大小自适应
    NSDictionary *attrbutes = @{NSForegroundColorAttributeName : [UIColor blackColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:17 * kWidthScale]};
    [[UINavigationBar appearance] setTitleTextAttributes:attrbutes];


}

// 重写navigationController的push和pop方法 使navigationBar的返回按钮不是固定样式 而是自定义样式
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.childViewControllers.count > 0) {
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.fll_height = 40;
        backButton.fll_width = 40;
        backButton.contentHorizontalAlignment = 1;
        [backButton setImage:[UIImage imageNamed:@"nav_back_black"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)back:(UIButton *)btn {
    [self popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
